><

JavaScript source



The JavaScript source icon () contains the JavaScript code which gets executed by the action when it runs. You can include any number of JavaScript code snippets in this area, either creating your own or including some of the .scpt files included in the actions folder. To edit the JavaScript, double-click on it to bring up the script editor and reveal the source code. Note that imported .scpt file includes are protected and cannot be edited in the script editor, you must edit the .scpt file directly. Scripts which you create from scratch can always be edited in this mode.

In this example double-clicking the script icon reveals the following code:

function CSOpenAlert(action) { alert(action[1]); }

The function name used in the script must be identical to that defined in the <csactionclass>. This function immediately calls the JavaScript alert method to display the alert box. The alert method takes a single parameter. By specifying action [1], you pass a value taken from the first data input field in your action--in this case, a "msg" box. In this way, all parameters defined by the <csactionparam> tag become arrays which can be referenced by their array number in any function. The first array, or action[0] (JavaScript is zero-based), refers to the function itself and should not be used. Thus, an action utilizing four parameters would use action[1] - action[4] to reference the parameters.


Creating Actions > Creating your own actions > JavaScript source